#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 1e5 + 10;
int a[N], b[N];

signed main() {
	IOS;
	int n, m, x;
	cin >> n >> m >> x;
	_for(i, 1, n)cin >> a[i];
	_for(i, 1, m)cin >> b[i];
	for(int i = 1, j = m; i <= n; ++i) {
		if(a[i] + b[j] == x) {
			cout << i - 1 << ' ' << j - 1 << endl;
			return 0;
		}
		while(a[i] + b[j] > x)j--;
	}
	return 0;
}

